class Solution:
    def lengthLongestPath(self, input: str) -> int:
        ans = 0
        stack = [0]
        for line in input.split('\n'):
            level = line.count('\t')
            name = line.replace('\t', '')
            while len(stack) > level :
                stack.pop()
            stack.append(len(name) + (0 if not stack else stack[-1]))

            if '.' in name:
                ans = max(ans, stack[-1] + level)
        
        return ans
